package com.reremouse.servlet;

import com.reremouse.rerebbs.dao.IBbsUserDAO;
import com.reremouse.rerebbs.model.BbsUser;
import com.reremouse.util.MD5;
import com.reremouse.util.SpringHelper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "RegisterActive", urlPatterns = {"/servlet/RegisterActive"})
public class RegisterActivate
        extends HttpServlet {
    public void destroy() {
        super.destroy();
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        IBbsUserDAO clientUserDAO = (IBbsUserDAO) SpringHelper.getSpringBean("BbsUserDAO");
        String urn = request.getParameter("urn");
        String sign = request.getParameter("sign");
        if ((urn == null) || (sign == null)) {
            return;
        }
        BbsUser cu = clientUserDAO.findBbsUserByUrn(urn);
        String temp = MD5.MD5Encode(new Long(cu.getId().longValue()).toString());
        if (!sign.equalsIgnoreCase(temp)) {
            return;
        }
        clientUserDAO.activateUser(cu.getId().longValue());
        response.sendRedirect(request.getContextPath() + "/talk/ActivateOk.jspx");
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
        out.println("<HTML>");
        out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
        out.println("  <BODY>");
        out.print("    This is ");
        out.print(super.getClass());
        out.println(", using the POST method");
        out.println("  </BODY>");
        out.println("</HTML>");
        out.flush();
        out.close();
    }

    public void init()
            throws ServletException {
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.servlet.RegisterActivate

 * JD-Core Version:    0.7.0.1

 */